<template>
  <div>
    <el-dialog v-bind="$attrs" v-on="$listeners" @open="onOpen" @close="onClose" :visible=visable title="添加沟通记录">
      <el-row :gutter="15">
        <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="107px">
          <el-col :span="12">
            <el-form-item label="跟进状态" prop="field105">
              <el-select v-model="formData.field105" placeholder="请选择跟进状态" clearable :style="{width: '100%'}">
                <el-option v-for="(item, index) in field105Options" :key="index" :label="item.label"
                  :value="item.value" :disabled="item.disabled"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="下次跟进时间" prop="field109">
              <el-date-picker v-model="formData.field109" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                :style="{width: '100%'}" placeholder="请选择下次跟进时间" clearable></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="沟通重点" prop="field104">
              <el-checkbox-group v-model="formData.field104" size="medium">
                <el-checkbox v-for="(item, index) in field104Options" :key="index" :label="item.value"
                  :disabled="item.disabled">{{item.label}}</el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="沟通纪要" prop="field111">
              <el-input v-model="formData.field111" type="textarea" placeholder="请输入沟通纪要"
                :autosize="{minRows: 4, maxRows: 4}" :style="{width: '100%'}"></el-input>
            </el-form-item>
          </el-col>
 <!--          <el-col :span="6">
            <el-form-item label="保存" prop="save">
              <el-button type="primary" icon="el-icon-search" size="medium"> 主要按钮 </el-button>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="退回公海" prop="field113">
              <el-button type="primary" icon="el-icon-search" size="medium"> 主要按钮 </el-button>
            </el-form-item>
          </el-col> -->
          <!-- <el-col :span="6">
            <el-form-item label="转成客户" prop="field114">
              <el-button type="primary" icon="el-icon-search" size="medium"> 主要按钮 </el-button>
            </el-form-item>
          </el-col> -->
        </el-form>
      </el-row>
      <div slot="footer">
        <el-button @click="close">保存</el-button>
        <el-button type="primary" @click="returnPool">退回公海</el-button>
        <el-button type="primary" @click="changeCustomer">转成客户</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { backBusiness, setCustomer } from '@/api/business/business'
export default {
  inheritAttrs: false,
  components: {},
  props: ['dataList', 'visable', 'queryParams'],
  data () {
    return {
      formData: {
        field105: undefined,
        field109: null,
        field104: [],
        field111: undefined,
        save: undefined,
        field113: undefined,
        field114: undefined,
      },
      rules: {
        field105: [{
          required: true,
          message: '请选择跟进状态',
          trigger: 'change'
        }],
        field109: [{
          required: true,
          message: '请选择下次跟进时间',
          trigger: 'change'
        }],
        field104: [{
          required: true,
          type: 'array',
          message: '请至少选择一个field104',
          trigger: 'change'
        }],
        field111: [{
          required: true,
          message: '请输入沟通纪要',
          trigger: 'blur'
        }],
      },
      field105Options: [{
        "label": "接通",
        "value": 1
      }, {
        "label": "未接通",
        "value": 2
      }],
      field104Options: [{
        "label": "价格",
        "value": 1
      },
      {
        "label": "师资",
        "value": 2
      },{
        "label": "位置",
        "value": 3
      },{
        "label": "时间",
        "value": 4
      },{
        "label": "其它",
        "value": 5
      }],
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {

    close () {
      this.$emit('closeDialog', false)
    },
    returnPool () {
      this.$emit('returnPool', false)
      console.log(this.dataList)
      backBusiness(this.dataList)
        .then(res => {
          this.$message({
            message: '操作成功',
            type: 'success'
          })
        })
      this.$emit('queryBusinessList')
    },
    changeCustomer () {
      this.$emit('changeCustomer', false)
      console.log(this.dataList.id)
      setCustomer(this.dataList.id)
        .then(res => {
          this.$message({
            message: '操作成功',
            type: 'success'
          })
        })
      this.$emit('queryBusinessList')
    },
    onOpen () {},
    onClose () {
      this.$refs['elForm'].resetFields()
    },
    handleConfirm () {
      this.$refs['elForm'].validate(valid => {
        if (!valid) return
        this.close()
      })
    }
  }
}

</script>
<style>
</style>
